package com.hhsj.design.pullableview.view;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;

import com.hhsj.design.pullableview.ability.IPullUpAble;

public abstract class ILoadMoreView {

    protected Context mContext;
    protected View mView;

    public ILoadMoreView(Context context, @LayoutRes int layoutId) {
        mContext = context;
        mView = View.inflate(context, layoutId, null);
        createView(mView);
        mView.setLayoutParams(new FrameLayout.LayoutParams(createLayoutParams()));
    }

    public ILoadMoreView(Context context, View view) {
        mContext = context;
        mView = view;
        createView(mView);
        mView.setLayoutParams(new FrameLayout.LayoutParams(createLayoutParams()));
    }

    public abstract ViewGroup.MarginLayoutParams createLayoutParams();

    public abstract void createView(View view);

    public abstract int getLoadMoreHeight();

    /**
     * 开始动画
     */
    public abstract void startAnim();

    /**
     * 结束动画
     */
    public abstract void stopAnim();

    /**
     * 更新文字
     *
     * @param text
     */
    public abstract void updateText(@NonNull String... text);

    public abstract void updateWithState(IPullUpAble.FooterState state);

    /**
     * Get footer view bottom margin.
     *
     * @return
     */
    public abstract int getBottomMargin();

    @NonNull
    public final View getLoadMoreView() {
        return mView;
    }
}
